import 'dart:io';

import 'package:flutter/material.dart';

void main() {
  runApp(new PopupmenuButtonPlugin());
}

/*
 * 弹出菜单控件，点击控件会出现菜单 <br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
class PopupmenuButtonPlugin extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new PopupmenuButtonPluginState();
  }
}

/*
 * 页面功能 <br/>
 */
class PopupmenuButtonPluginState extends State<StatefulWidget> {
  final key_btn_right = GlobalKey();

  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    AppBar appBar = AppBar(
      leading: new IconButton(
        icon: new Icon(Icons.arrow_back),
        onPressed: () {},
      ),
      title: new Text('FlutterDesign'),
      centerTitle: true,
      actions: <Widget>[
        PopupMenuButton(
          onSelected: (value) {
            print(value);
          },
          itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
            new PopupMenuItem(value: "选项一的内容", child: new Text("选项一")),
            new PopupMenuItem(value: "选项二的内容", child: new Text("选项二"))
          ],
        ),
      ],
      backgroundColor: Colors.blue,
    );

    return MaterialApp(
      home: new Scaffold(
        appBar: appBar,
        body: new Builder(builder: (BuildContext context) {
          return ButtonBar(
            children: <Widget>[
              CloseButton(),
              BackButton(),
            ],
          );
        }),
        backgroundColor: Colors.white,
        bottomNavigationBar: null,
      ),
    );
  }

  /*
   * 显示SnackBar
   */
  void showSnackBar(context, String msg, {String label = '确定'}) {
    final snackBar = new SnackBar(
      content: new Text(msg),
      action: new SnackBarAction(label: label, onPressed: onSnackBarPressed),
    );
    Scaffold.of(context).showSnackBar(snackBar);
  }

  /*
   * SnackBarAction点击回调
   */
  void onSnackBarPressed() {}
}
